ActionController::Routing::Routes.draw do |map|
  # The priority is based upon order of creation: first created -> highest priority.
  
  # Sample of regular route:
  # map.connect 'products/:id', :controller => 'catalog', :action => 'view'

  # project controller
  map.connect 'project/:id/show', :controller => 'project', :action => 'show'
  map.connect 'project/:id/edit', :controller => 'project', :action => 'edit'

  # iteration controller
  map.connect 'project/:id/iteration/list', :controller => 'iteration', :action => 'list'
  map.connect 'project/:id/iteration/add',  :controller => 'iteration', :action => 'add'
  map.connect 'iteration/:id/show',         :controller => 'iteration', :action => 'show'
  map.connect 'iteration/:id/edit',         :controller => 'iteration', :action => 'edit'

  # user controller
  map.connect 'user/:id/show',     :controller => 'user', :action => 'show'
  map.connect 'user/:id/edit',     :controller => 'user', :action => 'edit'
  map.connect 'user/:id/project/list', :controller => 'user', :action => 'projects'
  map.connect 'user/:id/current_task', :controller => 'task', :action => 'current'

  # task controller
  map.connect 'project/:project_id/task/list',    :controller => 'task', :action => 'list'
  map.connect 'iteration/:iteration_id/task/list',:controller => 'task', :action => 'list'
  map.connect 'project/:project_id/task/add',     :controller => 'task', :action => 'add'
  map.connect 'iteration/:iteration_id/task/add', :controller => 'task', :action => 'add'
  map.connect 'task/:id/show',        :controller => 'task', :action => 'show'
  map.connect 'task/:id/edit',        :controller => 'task', :action => 'edit'
  map.connect 'task/:id/take',        :controller => 'task', :action => 'take'
  map.connect 'task/:id/steal',       :controller => 'task', :action => 'steal'
  map.connect 'task/:id/close',       :controller => 'task', :action => 'close'
  map.connect 'task/:id/status/open', :controller => 'task', :action => 'open'

  # session controller
  map.connect 'task/:id/history',       :controller => 'session', :action => 'list'
  map.connect 'task/:id/session/stop',  :controller => 'session', :action => 'stop'
  map.connect 'task/:id/session/start', :controller => 'session', :action => 'start'

  # comment controller
  map.connect 'project/:project_id/comment/add',     :controller => 'comment', :action => 'add'
  map.connect 'iteration/:iteration_id/comment/add', :controller => 'comment', :action => 'add'
  map.connect 'task/:task_id/comment/add',           :controller => 'comment', :action => 'add'
  map.connect 'project/:project_id/comment/list',     :controller => 'comment', :action => 'list'
  map.connect 'iteration/:iteration_id/comment/list', :controller => 'comment', :action => 'list'
  map.connect 'task/:task_id/comment/list',           :controller => 'comment', :action => 'list'

  # root controller
  map.connect 'search', :controller => "root", :action => 'search'
  map.connect 'search/export/tasks.csv', :controller => "root", :action => 'export'

  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # You can have the root of your site routed by hooking up '' 
  # -- just remember to delete public/index.html.
  # map.connect '', :controller => "welcome"
  map.connect '',       :controller => "root", :action => 'home'
  map.connect 'home',   :controller => "root", :action => 'home'

  # Allow downloading Web Service WSDL as a file with an extension
  # instead of a file named 'wsdl'
  map.connect ':controller/service.wsdl', :action => 'wsdl'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id'

  map.error ':controllername',  :controller => 'root', :action => '404'
end
